//SUMMARY: This do file replicates regional-level results from Ballard-Rosa, Malik, Rickard & Scheve (2021)

clear all
set more off

//Set directory
cd "C:\Users\cambr\Dropbox\Conjoint Taxation\UK study\AuthoritarianDraft\Submissions\CPS\Replication materials\"

use "Data\Regional data\Full merge (LAD2011).dta", clear

* Define shock variables
gen ln_shock = ln(ipw_1991_2007_weighted)
label var ln_shock "ln $\Delta$ IPW (1991-2007)"
gen ln_shockUS = ln(ipwUS_1991_2007_weighted)
label var ln_shockUS "ln $\Delta$ IPW (US, 1991-2007)"

//TABLE A3: Labor market consequences
gen chgManuf_1991_2007 = pcmanufemp2007 - pcmanufemp1991
reg chgManuf_1991_2007 ln_shock
outreg2 using  "Output\labor_market_results", replace ctitle(\Delta % Manuf. Emp. 91-07 OLS) tex(frag) nocons bdec(3) label
ivreg chgManuf_1991_2007 (ln_shock = ln_shockUS)
outreg2 using  "Output\labor_market_results", append ctitle(\Delta % Manuf. Emp. 91-07 IV) tex(frag) nocons bdec(3) label
reg wage_median2007 ln_shock
outreg2 using  "Output\labor_market_results", append ctitle(Med. wage '07 OLS) tex(frag) nocons bdec(3) label
ivreg wage_median2007 (ln_shock = ln_shockUS)
outreg2 using  "Output\labor_market_results", append ctitle(Med. wage '07 IV) tex(frag) nocons bdec(3) label

//TABLE A4: Regional mobility
gen log_pop2007 = log(totalpop2007)
gen log_pop1991 = log(totalpop1991)
gen chgLogPop_1991_2007 = log_pop2007 - log_pop1991
reg log_pop2007 ln_shock
ivreg log_pop2007 (ln_shock = ln_shockUS)
outreg2 using  "Output\mobility2", replace ctitle(Log pop.) tex(frag) nocons bdec(3) label
reg chgLogPop_1991_2007 ln_shock
ivreg chgLogPop_1991_2007 (ln_shock = ln_shockUS)
outreg2 using  "Output\mobility2", append ctitle(\Delta Log pop.) tex(frag) nocons bdec(3) label
reg outMigration_all ln_shock
ivreg outMigration_all (ln_shock = ln_shockUS)
outreg2 using  "Output\mobility2", append ctitle(Out migrants (#)) tex(frag) nocons bdec(3) label
gen migration_pop = outMigration_all / totalpop2007
reg migration_pop ln_shock
ivreg migration_pop (ln_shock = ln_shockUS)
outreg2 using  "Output\mobility2", append ctitle(Out migrants (% pop.)) tex(frag) nocons bdec(3) label

//TABLE A15:  Regional outmigration by skill type
ivreg outMigration_highManagement (ln_shock = ln_shockUS)
gen management_pop = outMigration_highManagement / totalpop2007 * 1000
ivreg management_pop (ln_shock = ln_shockUS)
outreg2 using  "Output\mobility_bySkill", replace ctitle(High management) tex(frag) nocons bdec(3) label
ivreg outMigration_lowManagement (ln_shock = ln_shockUS)
gen lowManagement_pop = outMigration_lowManagement / totalpop2007 * 1000
ivreg lowManagement_pop (ln_shock = ln_shockUS)
outreg2 using  "Output\mobility_bySkill", append ctitle(Low management) tex(frag) nocons bdec(3) label
ivreg outMigration_intermediate (ln_shock = ln_shockUS)
gen intermediate_pop = outMigration_intermediate / totalpop2007 * 1000
ivreg intermediate_pop (ln_shock = ln_shockUS)
outreg2 using  "Output\mobility_bySkill", append ctitle(Intermed.) tex(frag) nocons bdec(3) label
ivreg outMigration_smallEmployers (ln_shock = ln_shockUS)
gen smallEmployers_pop = outMigration_smallEmployers / totalpop2007 * 1000
ivreg smallEmployers_pop (ln_shock = ln_shockUS)
outreg2 using  "Output\mobility_bySkill", append ctitle(Small employer) tex(frag) nocons bdec(3) label
ivreg outMigration_technical (ln_shock = ln_shockUS)
gen technical_pop = outMigration_technical / totalpop2007 * 1000
ivreg technical_pop (ln_shock = ln_shockUS)
outreg2 using  "Output\mobility_bySkill", append ctitle(Technical) tex(frag) nocons bdec(3) label
ivreg outMigration_semiroutine (ln_shock = ln_shockUS)
gen semiroutine_pop = outMigration_semiroutine / totalpop2007 * 1000
ivreg semiroutine_pop (ln_shock = ln_shockUS)
outreg2 using  "Output\mobility_bySkill", append ctitle(Semi-routine) tex(frag) nocons bdec(3) label
ivreg outMigration_routine (ln_shock = ln_shockUS)
gen routine_pop = outMigration_routine / totalpop2007 * 1000
ivreg routine_pop (ln_shock = ln_shockUS)
outreg2 using  "Output\mobility_bySkill", append ctitle(Routine) tex(frag) nocons bdec(3) label
ivreg outMigration_unemployed (ln_shock = ln_shockUS)
gen unemployed_pop = outMigration_unemployed / totalpop2007 * 1000
ivreg unemployed_pop (ln_shock = ln_shockUS)
outreg2 using  "Output\mobility_bySkill", append ctitle(Unemp.) tex(frag) nocons bdec(3) label
ivreg outMigration_students (ln_shock = ln_shockUS)
gen students_pop = outMigration_students / totalpop2007 * 1000
ivreg students_pop (ln_shock = ln_shockUS)
outreg2 using  "Output\mobility_bySkill", append ctitle(Students) tex(frag) nocons bdec(3) label
